package com.bwie.es.controller;

import com.bwie.common.core.web.domain.AjaxResult;
import com.bwie.sku.domain.vo.SearchResult;
import com.bwie.es.service.EsService;
import com.bwie.sku.domain.dto.SearchParam;
import com.bwie.spu.domain.SkuEsModel;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.io.IOException;
import java.util.List;

@RestController
@RequestMapping("es")
@CrossOrigin
public class EsController {
    /**
     * 导入
     */
    @Autowired
    private EsService service;

    /**
     * 同步到es
     * @param esModelList
     * @return
     */
    @PostMapping("up")
    public AjaxResult up (@RequestBody List<SkuEsModel> esModelList) throws IOException {
        // 调用service
        service.up(esModelList);
        //返回
        return AjaxResult.success();
    }

    @PostMapping("getTableSkuInfo")
    public SearchResult getTableSkuInfo(@RequestBody SearchParam searchParam) throws IOException {
        SearchResult searchResult = service.getTableSkuInfo(searchParam);
        //返回
        return searchResult;
    }
}
